<?
	
	//require_once('../fun/accounts.php');
	require_once('../fun/disorders.php');
	$results = array();
	if(isset($_POST['id']))
	{
		$row = $_POST;
		$results = ValidateDisorder($row);
		if($results === true)
			$results = CreateDisorder($row);
		if($results === true)
		{
			if(isset($_REQUEST['ajax'])){
				$rs = GetDisorder($row['id']);
			}else{
				header("Location: index.php");
			}
			die();
		}
	}else{
		if(isset($_REQUEST['id']))
			$row = GetDisorder($_REQUEST['id']);
		else
			$row = BlankDisorder();
	}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>&psi; Psychology Database &psi;</title>
<? include ("../inc/required-links.php") ?>
</head>

<body>
<div id="wrapper">
	<div id="l_l"></div> 
    <div id="left">
		<?php include ('../nav/disorders.php') ?>
    </div>
    <div id="main">
		<?php include ('../inc/header.php') ?>
        <div id="t_bg"></div>
        <div id="content">
			<div class="otstup">
            	<div id="main_left">
					<div class="corners">
                    	<div class="text">
                <form class="createForm formPost" method="post" action="edit.php" style="width:420px;">
                    <div class="modal-header" style="text-align:center;"><h1>Explain Disorder</h1></div>
                    <div class=" control-group">
                        <label for="Name">Name:</label>
                        <div class="controls">
                            <input type="text" name="Name" id="Name" value="<?=$row['Name']?>"
                            class="required <?=isset($results['Name']) ? 'error' : '' ?>" style="width:400px;" />
                            <span class="error"><?=isset($results['Name']) ? $results['Name'] : '' ?></span>
                        </div>
                    </div>
                    <div>
                        <label for="Description">Description:</label>
                        <div class="controls">
                            <input type="text" name="Description" id="Description" value="<?=$row['Description']?>"
                            class="required <?=isset($results['Description']) ? 'error' : '' ?>" style="width:400px;" />
                            <span class="error"><?=isset($results['Description']) ? $results['Description'] : '' ?></span>
                        </div>
                    </div>
                    <div>
                        <label for="DiagnosticCriteria">Diagnostic Criteria:</label>
                        <div class="controls">
                            <input type="text" name="DiagnosticCriteria" id="DiagnosticCriteria" value="<?=$row['DiagnosticCriteria']?>"
                            class="required <?=isset($results['DiagnosticCriteria']) ? 'error' : '' ?>" style="width:400px;" />
                            <span class="error"><?=isset($results['DiagnosticCriteria']) ? $results['DiagnosticCriteria'] : '' ?></span>
                        </div>
                    </div>
                    <div>
                        <label for="Statistics">Statistics:</label>
                        <div class="controls">
                            <input type="text" name="Statistics" id="Statistics" value="<?=$row['Statistics']?>"
                            class="required <?=isset($results['Statistics']) ? 'error' : '' ?>" style="width:400px;" />
                            <span class="error"><?=isset($results['Statistics']) ? $results['Statistics'] : '' ?></span>
                        </div>
                    </div>
                    <div>
                        <label for="MiniCase">MiniCase:</label>
                        <div class="controls">
                            <input type="text" name="MiniCase" id="MiniCase" value="<?=$row['MiniCase']?>"
                            class="required <?=isset($results['MiniCase']) ? 'error' : '' ?>" style="width:400px;" />
                            <span class="error"><?=isset($results['MiniCase']) ? $results['MiniCase'] : '' ?></span>
                        </div>
                    </div>
                    <div>
                        <label for="MCDiagnostics">Mini Case Diagnostics:</label>
                        <div class="controls">
                            <input type="text" name="MCDiagnostics" id="MCDiagnostics" value="<?=$row['MCDiagnostics']?>"
                            class="required <?=isset($results['MCDiagnostics']) ? 'error' : '' ?>" style="width:400px;" />
                            <span class="error"><?=isset($results['MCDiagnostics']) ? $results['MCDiagnostics'] : '' ?></span>
                        </div>
                    </div>
                    <div class="control-group modal-footer">
                       <input type="hidden" name="id" id="id" value="<?=$row['id']?>" />
                       <input class="btn btn-mini" style="margin-top:10px;" type="submit" value="Update" />
                    </div>
                </form>
                <br /><a href="http://cs.newpaltz.edu<?=$_GET['returnUrl']?>">Cancel</a>
                		</div>
                    </div>
                </div>
                <div id="right">
					<?php include ('../inc/cat_box1.php') ?>
					<?php include ('../inc/cat_box3.php') ?>
					<?php include ('../inc/cat_box4.php') ?>
					<?php include ('../inc/sn_links.php') ?>
                </div>
        		<div class="clear"></div>
        	</div>
        </div>
        <div class="clear"></div>  
        <div id="foot">
        	<?php include ('../inc/footer.php') ?>
		</div>
		<?php include ('../inc/copywright.php') ?>
        </div>
<div class="clear"></div> 
</div>
</body>
</html>
<? include ("../inc/required-js.php") ?>
